package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.wemedia.dto.ChannelDto;
import com.zhentao.model.wemedia.pojo.WmChannel;
import com.zhentao.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult findAll() {
        return wmChannelService.findAll();
    }

    /**
     * 删除频道
     *
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable Integer id) {
        return wmChannelService.del(id);
    }

    @PostMapping("/list")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto) {
        return wmChannelService.findByNameAndPage(dto);
    }

    @PostMapping("/save")
    public ResponseResult insert(@RequestBody WmChannel adChannel) {
        return wmChannelService.insert(adChannel);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel adChannel) {
        return wmChannelService.update(adChannel);
    }
}
